package com.healthySys.common.result;

import lombok.Data;

@Data
public class Result<T> {

    private Integer code;
    private String msg;
    private T data;

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result<String> success(){
        return new Result<>(1,"操作成功",null);
    }
    public static Result<Void> success(String msg){
        return new Result<>(1,msg,null);
    }

    public static<T> Result<T> success(T data){
        return new Result<>(1,"操作成功",data);
    }

    public static Result<String> error(){
        return new Result<>(1,"操作失败",null);
    }
    public static Result<Void> error(String msg){
        return new Result<>(1,msg,null);
    }
    public static<T> Result<T> error(T data){
        return new Result<>(1,"操作失败",data);
    }
    public static<T> Result<T> error(Integer code, String msg){
        return new Result<>(code,msg,null);
    }

    public static<T> Result<T> success(String msg, T data) {
        return new Result<>(1,msg,data);
    }
}
